package com.example.excel.dao;

import com.example.excel.entity.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


//数据访问层
public interface StuDao {

    @Select("select * from student")
    List<Student> findAll();

    @Insert("insert into student (name, sex, age, address) VALUE (#{name}, #{sex}, #{age}, #{address})")
    void addStudent(Student student);

    @Select("select count(*) from student where name = #{name}")
    int countForName(String name);

    @Select("select count(*) from student where password = MD5(#{pwd})")
    int countForPwd(String pwd);

    @Select("select count(*) from student where name = #{name} && password = MD5(#{pwd})")
    int countForLogin(@Param("name") String name,@Param("pwd")  String pwd);

    @Select("select * from student where name = #{name} && password = MD5(#{pwd})")
    Student oneStudent(@Param("name") String name,@Param("pwd")  String pwd);
}
